home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / utility3 / wtj008.zip / NOTBAD.ZIP / OPENFILE.H < prev    next >
C/C++ Source or Header  |  1992-06-15  |  2KB  |  75 lines

  1. // openfile.h RHS 3/31/91
  2.  
  3. #if !defined(OPENFILE_H)
  4. #define OPENFILE_H
  5.  
  6. #include<windows.h>
  7. #include<stdio.h>
  8. #include<string.h>
  9.  
  10. #define OPENFILE_FILEOPEN   0x00
  11. #define OPENFILE_FILESAVE   0x01
  12.  
  13. class OpenFileDlg
  14.     {
  15. private:
  16.     static char filename[FILENAME_MAX];
  17.     static char openname[FILENAME_MAX];
  18.     static char defpath[FILENAME_MAX];
  19.     static char defspec[13];
  20.     static char default_extension[4];
  21.     static char str[FILENAME_MAX*2];
  22.     static unsigned hEditBox, hListBox, hPath;
  23.     static char caption[20];
  24.     static char buttontext[20];
  25.     static char mode;
  26.     static WORD attribute;
  27.  
  28.     static void UpdateListBox(HWND hDlg);
  29.     static void ChangeDfExt(char *Ext, char *Name);
  30.     static void SeparateFilePath(LPSTR lpDestPath,
  31.             LPSTR lpDestFileName, LPSTR lpSrcFileName);
  32.     static void AddExtension(char *Name, char *Ext);
  33.     void SetDefaults(void)
  34.         {
  35.         hEditBox = hListBox = hPath = 0;
  36.         }
  37. public:
  38.     OpenFileDlg(char *dspec = "*.TXT", char *dext = ".TXT")
  39.         {
  40.         SetDefaults();
  41.         strcpy(defspec,dspec);
  42.         strcpy(default_extension,dext);
  43.         }
  44.     OpenFileDlg(char *dspec, char *dext, char *newcap, char *btext)
  45.         {
  46.         OpenFileDlg(dspec,dext);
  47.         SetCaption(newcap);
  48.         SetButtonText(btext);
  49.         }
  50.     void Init(char *newext, char *newspec, 
  51.             unsigned hEB, unsigned hLB, unsigned hPth, char newmode)
  52.         {
  53.         SetDefExtension(newext);
  54.         SetDefSpec(newspec);
  55.         hEditBox = hEB;
  56.         hListBox = hLB;
  57.         hPath = hPth;
  58.         mode = newmode;
  59. //        attr = attribute;
  60.         }
  61.     void SetDefExtension(char *newext)  
  62.         {   
  63.         strcpy(default_extension,newext);   
  64.         }
  65.     void SetDefSpec(char *newspec)  {   strcpy(defspec,newspec);    }
  66.     char *GetFileName(void)         {   return filename;            }
  67.     void SetCaption(char *newcap)   {   strcpy(caption,newcap);     }
  68.     void SetButtonText(char *newtext){  strcpy(buttontext,newtext); }
  69.  
  70.     static BOOL CALLBACK DlgProc(HWND, UINT, WPARAM, LPARAM);
  71.     };
  72.  
  73. #endif
  74.  
  75.